package com.unknownman.block.config;

import com.unknownman.block.annotation.TransactionSenderAspect;
import com.unknownman.block.rabbitmq.send.RabbitSender;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 先把rabbitmq加入到这里来，到时候要根据配置向各个业务系统发送消息，现在暂时放在同一个数据库里处理
 */
@Aspect
@Configuration
@ConditionalOnProperty(prefix = "system.rabbitmq", name = "enabled", havingValue = "true")
public class RabbitMqSenderConfig {

    @Bean
    RabbitSender rabbitSender() {
        return new RabbitSender();
    }

    @Bean
    TransactionSenderAspect transactionSenderAspect(RabbitSender rabbitSender) {
        return new TransactionSenderAspect(rabbitSender);
    }

}
